package per.jdz.lock8;

import java.util.concurrent.TimeUnit;

public class Test3 {
    public static void main(String[] args) {
        Phone3 phone = new Phone3();
        Phone3 phone2 = new Phone3();
        new Thread(()-> {
            phone.sendSms();
        }).start();
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        new Thread(Phone3::call).start();
    }
}

class Phone3 {

    // 锁Class模板
    public static synchronized void sendSms() {
        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println("send sms");
    }

    public static synchronized void call() {
        System.out.println("call phone");
    }
    public void hello() {
        System.out.println("hello");
    }
}

